﻿#ifndef _PROXY_MSG_MGR_H_
#define _PROXY_MSG_MGR_H_

#include "message_factory.h"
#include "proxy_head.h"

typedef void(*ProxyMsgProcess)(const common::CProxyHead& head, const CJsonMessageBase& msg);

class CProxyMsgFactory
{
public:
	typedef std::unordered_map< int, ProxyMsgProcess >	TMsgProcess;

public:
	CProxyMsgFactory();

	ProxyMsgProcess GetMsgProcess(int msg_id);

	template< typename T >void RegisteMsg(int msg_id, ProxyMsgProcess process)
	{
		msg_factory_.RegistePBMsg< T >(msg_id);
		msg_process_.insert(TMsgProcess::value_type(msg_id, process));
	}

	void RegisteMsgJson(int msg_id, ProxyMsgProcess process)
	{
		msg_factory_.RegistePBMsg< CJsonMessageBase >(msg_id);
		msg_process_.insert(TMsgProcess::value_type(msg_id, process));
	}

	CPBMsgFactory& GetMsgFactory() { return msg_factory_; }

private:
	CPBMsgFactory	msg_factory_;
	TMsgProcess		msg_process_;
};

#endif